home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 446_01 / DOC / DPBASICS / EX / MAT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  530 b   |  24 lines

  1. class mat
  2. {
  3.   // internal representation of a C matrix:
  4.   double** A;     // pointer to allocated space for the matrix entries
  5.   int m,n;        // A is an mxn matrix
  6.  
  7. public:
  8.   mat ();
  9.   mat (int m, int n);
  10.   BooLean redim (int m, int m);
  11.   void size (int& m, int& n);
  12.   double& operator () (int i, int j);
  13.   void print ();
  14. };
  15.  
  16. inline double& mat:: operator () (int i, int j)
  17. {
  18. #ifdef ARRAY_RANGECHECK
  19.   if (i<1 || i>m || j<1 || j>n)
  20.     printf("Index (%d,%d) is out of bounds (1:%d,1:%d)\n",i,j,m,n);
  21. #endif
  22.   return A[i][j];
  23. }
  24.